//https://leetcode.cn/problems/minimum-operations-to-halve-array-sum/

class Solution {
public:
    int halveArray(vector<int>& nums) {
        priority_queue<double> pq;
        double sum = 0.0;
        for (auto e : nums)
        {
            pq.push(e);
            sum += e;
        }
        sum /= 2.0;

        int count = 0;

        while (sum > 0)
        {
            double t = pq.top() / 2.0;
            pq.pop();

            sum -= t;
            pq.push(t);
            count++;

        }

        return count;

    }
};